package com.itsitio.registeradmin.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itsitio.registeradmin.dao.CompanyDao;
import com.itsitio.registeradmin.dao.CompanyFirmDao;
import com.itsitio.registeradmin.model.Company;
import com.itsitio.registeradmin.model.CompanyFirmName;
import com.itsitio.registeradmin.service.CompanyFirmSrv;

@Service
public class CompanyFirmSrvImpl implements CompanyFirmSrv{


	@Autowired
	private CompanyFirmDao companyFirmDao;
	
	@Autowired
	private CompanyDao companyDao;
	

	//@Override
	public CompanyFirmName createCompanyFirmFromUserRegistration(
			Integer selectedCompany, String firmName, String taxId) {
		
		Company company = companyDao.obtener(selectedCompany);
		
		CompanyFirmName companyFirm = new CompanyFirmName();
		companyFirm.setFirmName(firmName);
		companyFirm.setTaxId(taxId);
		companyFirm.setUpdateDate(new Date());
		companyFirm.setCompany(company);
		
		company.addCompanyFirm(companyFirm);
		companyDao.guardar(company);
		
		return companyFirm;
	}

}
